package com.cskaoyan.bean.vo.wx.order;

import lombok.Data;

/**
 * @author Aaliyah
 * @date 2022/9/9 15:49
 * @description: TODO
 */
@Data
public class HandleOption {

    // 订单状态码 - 数据库
    private static final Short UNPAID = 101;
    private static final Short USER_CANCEL = 102;
    private static final Short SYSTEM_CANCEL = 103;
    private static final Short ALREADY_PAID = 201;
    private static final Short APPLY_REFUND = 202;
    private static final Short ALREADY_REFUND = 203;
    private static final Short ALREADY_SHIP = 301;
    private static final Short ALREADY_RECEIVE = 401;
    private static final Short SYSTEM_RECEIVE = 402;


    private Boolean aftersale = false;  // 申请售后
    private Boolean cancel = false;  // 取消订单
    private Boolean comment = false;  // 去评论
    private Boolean confirm = false;  // 确认收货
    private Boolean delete = false;  // 删除订单
    private Boolean pay = false;  // 去付款
    private Boolean rebuy = false;  // 再次购买
    private Boolean refund = false;  // 申请退款

    /**
     * @description: 根据订单的状态信息，返回一个封装好的HandleOption
     * @date: 2022/9/9 19:11
     * @param: [orderStatus]
     */
    public static HandleOption setDataByOrderStatus(Short orderStatus) {

        HandleOption handleOption = new HandleOption();

        if (orderStatus.equals(UNPAID)){
            handleOption.setCancel(true);
            handleOption.setPay(true);
        }else if(orderStatus.equals(USER_CANCEL)) {
            handleOption.setCancel(true);
        }else if(orderStatus.equals(SYSTEM_CANCEL)) {
            // TODO
        }else if(orderStatus.equals(ALREADY_PAID)) {
            handleOption.setRefund(true);
        }else if (orderStatus.equals(APPLY_REFUND)){
            // 没有按钮
        }else if (orderStatus.equals(ALREADY_REFUND)){
            handleOption.setDelete(true);
        }else if (orderStatus.equals(ALREADY_SHIP)){
            handleOption.setConfirm(true);
        }else if (orderStatus.equals(SYSTEM_RECEIVE)){
            handleOption.setConfirm(true);
        }else if (orderStatus.equals(ALREADY_RECEIVE)){
            handleOption.setDelete(true);
            handleOption.setAftersale(true);
            handleOption.setRebuy(true);
            handleOption.setComment(true);
        }


        return handleOption;
    }
}
